package com.gxa.modules.service.zls.impl;

import com.gxa.common.vo.R2;
import com.gxa.modules.mapper.zls.ShopManageMapper;
import com.gxa.modules.service.zls.ShopManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: zls
 * Date: 2021/12/28 13:40:14
 * Description:
 * Version: V1.0
 */
@Service
public class ShopManageServiceImpl implements ShopManageService {
    @Autowired(required = false)
    private ShopManageMapper shopManageMapper;

    /**
     * 店铺列表查询
     * @param map
     * @return
     */
    @Override
    public R2 findShopList(Map map) {
        Integer page = (Integer) map.get("page");
        Integer limit = (Integer) map.get("limit");
        List<Map> mapList = shopManageMapper.findShopList((page-1)*limit,limit,map.get("status"),map.get("input"),map.get("startTime"),map.get("endTime"));
        return new R2(200,"查询成功",mapList);
    }

    /**
     * 店铺详情查询
     * @param shop_id
     * @return
     */
    @Override
    public R2 queryShop1(String shop_id) {
        Map map = shopManageMapper.queryShop1(shop_id);
        return new R2(200,"查询成功",map);
    }

    /**
     * 注册店铺
     * @param map
     * @return
     */
    @Override
    @Transactional
    public R2 addShop1(Map map) {
        Map map1 = shopManageMapper.queryUserId(map.get("user_phone"));
        if (map1.get("user_id") != null){
            map.put("user_id",map1.get("user_id"));
        }
        int i = shopManageMapper.addShop1(map);
        if(i>0){
            return new R2(200,"店铺信息注册成功");
        }
        return new R2(500,"店铺信息注册失败");
    }

    /**
     * 一键审核店铺
     * @param map
     * @return
     */
    @Override
    public R2 checkShop1(Map map) {
        int i = shopManageMapper.checkShop1(map);
        return new R2(200,"店铺审核成功");
    }

    /**
     * 设置店铺试用信息
     * @param map
     * @return
     */
    @Override
    public R2 updateTryShop(Map map) {
        int i = shopManageMapper.updateTryShop(map);
        return new R2(200,"提交试用设置成功");
    }
}
